use Template;
use warnings;
use strict;

my $tt = Template->new;
my $vars ;

my $tt1 = "zaptel";
die "cannot find $tt1.tt" unless -e "$tt1.tt";
my $tt2 = "zapata";
die "cannot find $tt2.tt" unless -e "$tt2.tt";

print "\n################# set channels####################\n";

my($zaptel, $zapata);
while(1) {
	print "zaptel: ";
	$zaptel = <STDIN>;
	chomp $zaptel;

	print "zapata: ";
	$zapata = <STDIN>;
	chomp $zapata;
CHECK:
	print "setting finished, Yes/No/Retry: ";
	my $state = <STDIN>;
	chomp $state;
	if ($state eq 'y' || $state eq 'Y'){
		last;
	} elsif($state eq 'n' || $state eq 'N') {
		print "settings be canceled\n";
		exit 0;
	} elsif($state eq 'r' || $state eq 'R') {	
		print "setting again\n";
	} else {
		goto CHECK;
	}
}
$vars->{fxoks} = $zaptel;
$vars->{fxsks} = $zapata;

$tt->process("$tt1.tt", $vars, "$tt1.conf") or die $tt->error;
$tt->process("$tt2.tt", $vars, "$tt2.conf") or die $tt->error;

print "OK!\n";